package com.springBoot.springBootSysCore.filter;

import com.springBoot.springBootSysCore.common.config.Global;
import org.sitemesh.SiteMeshContext;
import org.sitemesh.builder.SiteMeshFilterBuilder;
import org.sitemesh.config.ConfigurableSiteMeshFilter;
import org.sitemesh.content.ContentProperty;
import org.sitemesh.content.tagrules.TagRuleBundle;
import org.sitemesh.content.tagrules.html.ExportTagToContentRule;
import org.sitemesh.tagprocessor.State;

public class WebSiteMeshFilter extends ConfigurableSiteMeshFilter{
    String adminPath = Global.getAdminPath();
    @Override  
    protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
        builder.addDecoratorPath("/*", "/WEB-INF/views/layouts/default.jsp")
                .addExcludedPath("/static/**")
//                .addExcludedPath(adminPath+"/tag/treeSelect")
                .addExcludedPath("/web/**")
                .addExcludedPath(adminPath+"/login");
//       如果要这样处理 上面的路径不能为*
//        builder.addDecoratorPath(adminPath+"/tag/**", "/WEB-INF/views/layouts/simple.jsp");
        builder.addTagRuleBundle(new CustomTagRuleBundle());

    }

    public class  CustomTagRuleBundle implements TagRuleBundle {
        @Override
        public void install(State defaultState, ContentProperty contentProperty, SiteMeshContext siteMeshContext) {
            defaultState.addRule("myfooter", new ExportTagToContentRule(siteMeshContext, contentProperty.getChild("myfooter"), false));
        }
        @Override
        public void cleanUp(State defaultState, ContentProperty contentProperty, SiteMeshContext siteMeshContext) {

        }
    }
}  
